<%@ page contentType="text/html; charset=utf-8" pageEncoding="utf-8" %>
<%@ taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core" %>
<%@ taglib prefix="f" uri="http://java.sun.com/jsp/jstl/fmt" %>
<%@ taglib prefix="fn" uri="http://java.sun.com/jsp/jstl/functions" %>
<%@ taglib prefix="s" uri="http://stripes.sourceforge.net/stripes.tld" %>
<%@ taglib prefix="fmt" uri="http://java.sun.com/jsp/jstl/fmt" %>

<fmt:bundle basename="StripesResources" /> 
<fmt:message key='admin.abilityTitle' var="title"/>
<s:layout-render name="adminlayout.jsp" nadpis="${title}">
    <s:layout-component name="telo">
        <s:useActionBean beanclass="cz.muni.fi.pa165.hauntedhouses.web.AbilityActionBean" var="actionBean"/>
        <center>
            <c:choose>
                <c:when test="${fn:length(actionBean.abilities) == 0}">
                    <div><font style="color: red;" ><fmt:message key="menu.noabilities"/></font></div><br /><br />
                </c:when>
                <c:otherwise>
                    <table class="zakladni" >
                        <tr>
                            <th><fmt:message key="admin.abilityName"/></th>
                            <th><fmt:message key="admin.abilityDescription"/></th>
                            <th><fmt:message key="admin.abilityDamage"/></th>
                            <th><fmt:message key="admin.abilityLevel"/></th>
                            <th><fmt:message key="admin.abilityType"/></th>
                            <th><fmt:message key="admin.abilityEdit"/></th>
                            <th><fmt:message key="admin.abilityDelete"/></th>
                        </tr>

                        <c:forEach items="${actionBean.abilities}" var="ability">
                            <tr>
                                <td><c:out value="${ability.name}"/></td>
                                <td><c:out value="${ability.description}"/></td>
                                <td><c:out value="${ability.damage}"/></td>
                                <td><c:out value="${ability.abilityLevel}"/></td>
                                <td><c:out value="${ability.abilityType}"/></td>                    
                                <td><s:link beanclass="cz.muni.fi.pa165.hauntedhouses.web.AbilityActionBean" event="edit"><s:param name="ability.id" value="${ability.id}"/><fmt:message key="admin.abilityEdit"/></s:link> </td>
                                <td><s:link beanclass="cz.muni.fi.pa165.hauntedhouses.web.AbilityActionBean" event="delete"><s:param name="ability.id" value="${ability.id}"/><fmt:message key="admin.abilityDelete"/></s:link> </td>
                                </tr>
                        </c:forEach>
                    </table>
                </c:otherwise>
            </c:choose>
            <s:form style="width:400px" beanclass="cz.muni.fi.pa165.hauntedhouses.web.AbilityActionBean">
                <br /><fieldset><legend><fmt:message key="admin.newAbility"/></legend>
                    <%@include file="abilityForm.jsp"%>
                    <s:submit name="add"><fmt:message key="admin.createNewAbility"/></s:submit>
                    </fieldset>
            </s:form>
        </center>
    </s:layout-component>
</s:layout-render>

